<template>
	<public-view navType="log" navTitle="明细">
		<view class="content">
			<view class="log-list">
				<block v-for="(item, index) in list" :key="index">
					<view class="item flex j-c-b a-i-c">
						<view class="left">
							<view class="subtitle f-s-28">
								{{item.memo||""}}
							</view>
							<view class="time color-878787 f-s-24">
								时间：{{item.createtime||""}}
							</view>
						</view>
						<!-- color-F8A039 -->
						<view class="right color-ff4545 f-s-48 f-w-b">
							{{item.money||""}}
						</view>
					</view>
				</block>
			</view>
		</view>
	</public-view>
</template>

<script>
	import {mapGetters} from "vuex"
	export default {
		data() {
			return {
				page:1,
				list:[]
			};
		},
		computed:{
			...mapGetters(["logTab"])
		},
		watch:{
			"$store.state.log_tab":{
				handler(newVal,oldVal) {
				    // console.log(newVal,oldVal)
				},
			}
		},
		onLoad() {
			this.getLogList()
		},
		onReachBottom() {
			this.page++
			this.getLogList()
		},
		methods:{
			getLogList(){
				let that = this
				that.util.postRequest({
					url:"v1/user/getMoneylog",
					data:{
						page:that.page,
						rows:10
					}
				}).then(res=>{
					console.log(res)
					if(that.page === 1){
						that.list =res.data.data
					}else{
						if(res.data.data.length>0){
							that.list = that.list.concat(res.data.data)
						}else{
							that.page--
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		width: 750upx;
		padding: 34upx 0;
	}
	.log-list{
		width: 100%;
		padding: 0 40upx;
		.item{
			width: 100%;
			background: #FFFFFF;
			border-radius: 16upx;
			margin-bottom: 20upx;
			padding: 36upx;
			.left{
				.subtitle{
					line-height: 40upx;
					margin-bottom: 30upx;
				}
			}
		}
	}
</style>
